<?php
namespace Wap\Controller;
use Common\Model\UserModel;
use Common\Model\UtilsModel;
use Wap\BaseController;
use Common\Model\MarqueeModel;
class IndexController extends BaseController {
    public function index(){
        $uid = session('uid')+0;
        //是否当日首次签到
        signAssignWap($uid,$this->smarty);

        $this->smarty->assign('title',C('SITE_NAME').'-首页');
        $marqueeList=MarqueeModel::getMarqueeList(MarqueeModel::MARQUEE_WAP_INDEX,4,1);
        $this->smarty->assign('marquee',$marqueeList);

        $channels=getChannelKv();
        $this->smarty->assign('channels',$channels);
        $this->smarty->display("index.html");
    }

    public function jump(){
        $id=I('get.id',0,'int');
        $type=I('get.type',0,'int');
        $url=I('get.url','','urldecode');
        switch($type){
            case OBJ_TYPE_ACTIVITY:
                M('e_events',null,DB_MAIN_CFG)->where('id='.$id)->setInc('jumpTimes');
                break;
            case OBJ_TYPE_ARTICLE:
                break;
            case OBJ_TYPE_POINTMALL:
                break;
        }
        redirect($url);
    }
    //轮播跳转
    public function marqueJump(){
        $id=I('get.id',0,'int');
        if(!$id){
            $this->error('参数错误');
        }
        $marqueeInfo=M('marquee',null,DB_MAIN_CFG)->where("id={$id}")->find();
        if(!$marqueeInfo){
            $this->error('指定对象不存在');
        }
        $url='';
        switch($marqueeInfo['relatedType']+0){
            case OBJ_TYPE_ACTIVITY:
                $url=u("Wap/Events/info?id=".$marqueeInfo['relatedID']);
                break;
            case OBJ_TYPE_ARTICLE:
                $url=u("Wap/Article/detail?id=".$marqueeInfo['relatedID']);
                break;
            case OBJ_TYPE_POINTMALL:
                $url=u("Wap/PointMall/info?id=".$marqueeInfo['relatedID']);
                break;
            case OBJ_TYPE_STORE:
                $url=u("Wap/Business/detail?id=".$marqueeInfo['relatedID']);
                break;
            case OBJ_TYPE_OUTER://外站
                $url=$marqueeInfo['jumpUrl'];
                break;
            default:
                $this->error('类型错误');
        }
        redirect($url);
        die;
    }


    public function pointRule(){
        $this->smarty->assign('title','积分规则');
        $this->smarty->display("PointMall/pointRule.html");
    }

    public function pointDetail(){
        $this->smarty->assign('title','积分明细');
        $this->smarty->display("PointMall/pointDetail.html");
    }

}